#import <UIKit/UIKit.h>
#import "hack.h"

#import "TileView.h"
#import "MenuController.h"
#import "ActionControl.h"

#define TILE_SIZE 16
#define TILES_PER_ROW 40

@interface NetHackViewController : UIViewController <UITextFieldDelegate> {
	NSCondition *whoseTurnCondition;
	NSThread *whoseTurn;
	NSThread *uiThread;
	NSThread *nethackThread;
	
	UITextField *keyboardTextField;
	
	TileView *tileView;
	UILabel *messageLabel;
	UILabel *statusLabel;
	
	int createdWindows;
	int clearedWindows;
	int displayedWindows;
	int destroyedWindows;
	
	BOOL hasMessageChanged;
	BOOL shouldClearMessage;
	NSMutableString *messageText;
	
	BOOL hasStatusChanged;
	NSMutableString *statusText;
	
	BOOL shouldShowMenu;
	MenuController *menuController;
	
	char character;
	BOOL shouldDelay;
    
    
    ActionControl *actionControl;
}

+ (NetHackViewController *)nethack;
- (void) putCharacter: (char) c;


#pragma mark C Functions

const char *getAbsolutePath(const char *filename);

int clipX;
int clipY;
void clearTiles();
short tileAt(short x, short y);

int getCharacter();
void putString(winid wid, int attr, const char *text);
void printGlyph(int x, int y, int glyph);
void rawPrint(const char *text);
char ynFunction(const char *question, const char *choices, int defaultChoice);

winid createWindow(int windowType);
void clearWindow(winid windowId);
void displayWindow(winid windowId);
void destroyWindow(winid windowId);

void delayOutput();

void startMenu();
void addMenuItem(int glyph, const char *item);
void endMenu(const char *prompt);

@end
